<template>
    <div class="container">
        <h3>加工管理</h3>
            <el-row style="margin-top:20px;">
                <el-col :span="7">
                    <el-input placeholder="请输入关键词" v-model="searchName" style="width:300px;">
                        <i slot="prefix" class="el-input__icon el-icon-search" ></i>
                       
                        <el-button slot="append" @click="handleSearch">搜索</el-button>
                    </el-input>
                </el-col>
               
                <el-button type="primary" v-if="!added" @click="goaddprocess" style="float:right; margin-right: 10px">新增加工</el-button>
            </el-row>
                
            <el-table
                :data="tableData"
                border
                style="margin-top:20px;"
                ref="multipleTable"
                header-cell-class-name="table-header"
            >
                <el-table-column prop="productName" sortable label="产品名称"></el-table-column>
                <el-table-column prop="batch" sortable label="加工批号"></el-table-column>
                <el-table-column prop="totalNumber" sortable label="成品数量">
					<template slot-scope="scope">
						{{scope.row.totalNumber}}{{scope.row.units}}
					</template>
				</el-table-column>
                <el-table-column prop="grade" sortable label="品级"></el-table-column>
				<el-table-column prop="technology" sortable label="工艺工序"></el-table-column>
				<el-table-column prop="createtime" sortable label="加工时间"></el-table-column>
                <el-table-column label="操作" width="150" align="center">
                    <template slot-scope="scope">
                        <el-button
                            type="text"
                            v-if="!edit"
                            @click="handleCheck(scope.$index, scope.row)"
                        >查看</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage" :total="total"  @current-change="handleCurrentChange" style="margin-top:20px"></el-pagination>
    </div>
</template>

<script>
	import {process_findByList} from "@/request/api"
    export default {
        data() {
            return {
				images:[],
                total:0,
                currentPage:1,
                pagesize:10,
                searchName: '',
                tableData: [],
                form: {},
                idx: -1,
                id: -1,
                boxCode:'',
                boxCode1:'',
                del:true,
                added:true,
                edit:true,
                action:'',
            };
        },
        created(){
            
        },
        mounted(){
            this.init();
            this.judgmentAuthority();
        },
        methods: {
            goaddprocess(){
                this.$router.push({
                    path:'/process/addprocess'
                })
            },
            handleCurrentChange(val){
                this.currentPage = val
                this.init()
            },
            init(){
               let data = {
					page:this.currentPage
				}
				process_findByList(data).then((res)=>{
					this.tableData = res.rows
					this.total = res.total
			   })
            },
			handleCheck(index,row){
				this.$router.push({
					path:'/process/checkprocess',
					query:{id:row.processId}
				})
			},
            //搜索
            handleSearch(){
                
            },
            //跳转编辑页面
            handleEdit(index,row){
                
            },
            //删除
            handleDelete(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                   
                });
            },
            //判定操作按钮显示
            judgmentAuthority(){
                var type = JSON.parse(localStorage.getItem("userInfo")).appMenus
                type.map(item => {
                    if(item.appName == '种植平台'){
                        item.menus.map(item1 => {
                            if(item1.name == '加工管理' && item1.children != null){
                                for(var i = 0; i < item1.children.length; i++){
                                    if(item1.children[i].name == '新增') this.added = false;
                                    if(item1.children[i].name == '查看') this.edit = false;
                                }
                            }
                        })
                    }
                })
            }
           
        }
    }
</script>

<style scoped lang="less">
/deep/.upload-daoru{
    background: #eee;
    .el-upload{
        border: none;
        width: auto;
        height: auto;
        border-radius: 0;
        float: right;
        margin-right: 10px
    }
}
.el-table{ margin-top: 20px;}
 .el-pagination{
    text-align: center;
}
.el-pagination{
    text-align: center;
}
.el-col{
    margin-bottom:0;
}
</style>